import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { resolve } from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueSetupExtend(), vueJsx()],
  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
    },
    //在引入文件的时候自动加上后缀,配置这个之后就不用写后缀
    //但是在vue-router的index.ts中引入vue组件依旧需要加.vue的后缀
    // extensions: ['.js', '.ts', '.json', '.vue']
  },
  server: {
    host: 'www.corho.com',
    port: 8080,
    open: true,
    cors: true,
  },
  // 配置 css 全局注入
  css: {
    preprocessorOptions: {
      less: {
        additionalData: `
          @import "@/assets/styles/variables.less";
          @import "@/assets/styles/mixins.less";
        `
      }
    }
  }
})
